module polygam
implicit none
contains
function ppsi(n,x)
!Polygamma function
double precision ppsi,x,n,w(1),dfac
integer ifail,nn
external s14adf

nn=(floor(n)+ceiling(n))/2
call s14adf(x,nn,1,w,ifail)
ppsi=dfac(nn)*((-1.0d0)**(n+1.0d0))*w(1)
end function ppsi

end module polygam